﻿Imports System.Data
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types

Public Class Stock

    Dim objConn As OracleConnection
    Dim dtadapter As OracleDataAdapter
    Dim objCmd As New OracleCommand

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim strConnString As String = Login.strConn
            objConn = New OracleConnection(strConnString)
            Try
                objConn.Open()
            Dim str As String = CB1.SelectedItem.ToString
            Dim sql As String = "Select * from " + str
                objCmd = New OracleCommand(sql, objConn)
                objCmd.CommandType = CommandType.Text
                Dim da = New OracleDataAdapter(objCmd)
                Dim cb = New OracleCommandBuilder(da)
                Dim ds = New DataSet()

                da.Fill(ds)

                MDSearch.DataSource = ds.Tables(0)
                MsgBox("การค้นหาสำเร็จ")
            Catch ex As Exception
                MsgBox("ไม่สามารถค้นหาได้")
            Finally
                objConn.Dispose()
            End Try
    End Sub
End Class